import random

def pi(num_samples):
    inside_circle = 0
    total_samples = num_samples

    for _ in range(num_samples):
        x = random.uniform(0, 1)
        y = random.uniform(0, 1)
        if x**2 + y**2 <= 1:
            inside_circle += 1

    pi_estimate = 4 * inside_circle / total_samples
    return pi_estimate

num_samples = 10000000
estimated_pi = pi(num_samples)
print(estimated_pi)